<?php

namespace app\common\model;

use think\Model;


class AdvertisementProgre extends Model
{

    

    

    // 表名
    protected $name = 'association_progress';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'activity_method_text',
        'status_text',
        'reward_stated_text',
        'receive_stated_text',
        'examine_stated_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getActivityMethodList()
    {
        return ['1' => __('Activity_method 1'), '2' => __('Activity_method 2')];
    }

    public function getStatusList()
    {
        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5')];
    }

    public function getRewardStatedList()
    {
        return ['0' => __('Reward_stated 0'), '1' => __('Reward_stated 1')];
    }

    public function getReceiveStatedList()
    {
        return ['0' => __('Receive_stated 0'), '1' => __('Receive_stated 1')];
    }

    public function getExamineStatedList()
    {
        return ['0' => __('Examine_stated 0'), '2' => __('Examine_stated 2'), '3' => __('Examine_stated 3'), '4' => __('Examine_stated 4'), '5' => __('Examine_stated 5')];
    }


    public function getActivityMethodTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['activity_method']) ? $data['activity_method'] : '');
        $list = $this->getActivityMethodList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRewardStatedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['reward_stated']) ? $data['reward_stated'] : '');
        $list = $this->getRewardStatedList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getReceiveStatedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['receive_stated']) ? $data['receive_stated'] : '');
        $list = $this->getReceiveStatedList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getExamineStatedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['examine_stated']) ? $data['examine_stated'] : '');
        $list = $this->getExamineStatedList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function associationjobs()
    {
        return $this->belongsTo('AssociationJobs', 'jobs_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function association()
    {
        return $this->belongsTo('Association', 'id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
